package com.yanqu.road.server.gameplayer.module.activity.yearMaster;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yanqu.road.entity.activity.ActivityDisperseGoldInfo;
import com.yanqu.road.entity.activity.ActivityDisperseGoldResult;
import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.args.YearMasterGridTypeArgs;
import com.yanqu.road.entity.activity.yearMaster.GridDetail;
import com.yanqu.road.entity.activity.yearMaster.UserYearMasterData;
import com.yanqu.road.entity.activity.yearMaster.UserYearMasterDataResult;
import com.yanqu.road.entity.activity.yearMaster.YearMasterBoss;
import com.yanqu.road.entity.enums.*;
import com.yanqu.road.entity.log.LogYearMaster;
import com.yanqu.road.entity.util.PowerHelper;
import com.yanqu.road.entity.util.StrengthResult;
import com.yanqu.road.logic.bussiness.activity.YearMasterBussiness;
import com.yanqu.road.logic.pb.YearMasterPb;
import com.yanqu.road.pb.yearMaster.YearMasterProto;
import com.yanqu.road.server.GameServer;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.base.GeneralModule;
import com.yanqu.road.server.gameplayer.module.player.BagModule;
import com.yanqu.road.server.gameplayer.module.player.CurrencyModule;
import com.yanqu.road.server.gameplayer.module.player.DecorationModule;
import com.yanqu.road.server.gameplayer.module.player.PlayerModule;
import com.yanqu.road.server.logic.mail.MailManager;
import com.yanqu.road.server.manger.VipMgr;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.NormalActivityMgr;
import com.yanqu.road.server.manger.activity.yearMaster.YearMasterMgr;
import com.yanqu.road.server.manger.config.SystemOpenMgr;
import com.yanqu.road.server.manger.log.AutoLogMgr;
import com.yanqu.road.server.manger.log.LogMgr;
import com.yanqu.road.server.manger.player.UserMgr;
import com.yanqu.road.server.protocol.*;
import com.yanqu.road.utils.date.DateHelper;
import com.yanqu.road.utils.property.Property;
import com.yanqu.road.utils.property.PropertyHelper;
import com.yanqu.road.utils.string.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;


public class YearMasterModule extends GeneralModule {
    private static Logger logger = LogManager.getLogger(YearMasterModule.class.getName());
    //活动id            用户数据
    private Map<Integer, UserYearMasterData> userYearMasterDataMap;

    public YearMasterModule(GamePlayer player) {
        super(player);
    }

    @Override
    public boolean loadData() {
        //获取用户游戏数据
        userYearMasterDataMap = YearMasterBussiness.getUserYearMasterInfo(player.getUserId());
        return false;
    }

    @Override
    public boolean afterLoadData() {
        return true;
    }

    @Override
    public boolean saveData() {
        for (UserYearMasterData userYearMasterData : userYearMasterDataMap.values()) {
            if (userYearMasterData.isInsertOption()) {
                YearMasterBussiness.addUserData(userYearMasterData);
            } else if (userYearMasterData.isUpdateOption()) {
                YearMasterBussiness.updateUserData(userYearMasterData);
            }
        }
        return true;
    }


    public void afterLogin() {
        syncActivity();
    }


    /**
     * 使用体力道具
     *
     * @param goodsId
     */
    public UserYearMasterDataResult useGoods(int goodsId, int num) {
        UserYearMasterDataResult result = new UserYearMasterDataResult();
        result.setRet(0);
        ActivityInfo activityInfo = YearMasterMgr.getActivityInfo();
        //活动期间可以使用道具
        if (!ActivityMgr.activityInTime(activityInfo)) {
            result.setRet(GameErrorCode.E_YEAR_MASTER_ACTIVITY_NO_IN_TIME);
            return result;
        }

        UserYearMasterData userYearMasterData = getUserYearMasterData(activityInfo.getActivityId());
        if (activityInfo == null || userYearMasterData == null) {
            result.setRet(GameErrorCode.E_ACTIVITY_NO_FOUND);
            return result;
        }

        result.setUserYearMasterData(userYearMasterData);

        if (num < 1) {
            result.setRet(GameErrorCode.E_BAG_USE_GOODS_COUNT_LESS_ONE);
            return result;
        }

        if (eItemId.YEAR_MASTER_EGG.getValue() != goodsId) {
            result.setRet(GameErrorCode.E_BAG_ITEM_CAN_NO_USE);
            return result;
        }
        //使用体力道具
        if (checkGoods(goodsId, num)) {
            int newStrength = YearMasterMgr.getYearMasterActivityConfig().getRestoreBaseStrength() * num;
            if (reduceGoodsNum(goodsId, num)) {
                StrengthResult strengthResult = PowerHelper.reduceStrength(userYearMasterData.getPhysicalStrength(), -newStrength, YearMasterMgr.getYearMasterActivityConfig().getStrengthConfig(), userYearMasterData.getStrengthTime());//加体力用负数
                changeStrength(userYearMasterData, strengthResult);
            } else {
                //道具使用失败
                result.setRet(GameErrorCode.E_BAG_ITEM_NO_ENOUGH);
                return result;
            }
        } else {
            //道具数量不足
            result.setRet(GameErrorCode.E_BAG_ITEM_NO_ENOUGH);
            return result;
        }
        return result;
    }

    /**
     * 道具充足判断
     */
    private boolean checkGoods(int goodsId, int goodsNum) {
        Property property = new Property();
        property.addProperty(goodsId, BigInteger.valueOf(goodsNum));
        boolean bo = player.getModule(CurrencyModule.class).currencyIsEnough(property);
        return bo;
    }

    /**
     * 扣除道具
     */
    private boolean reduceGoodsNum(int goodsId, int goodsNum) {
        Property property = new Property();
        property.addProperty(goodsId, BigInteger.valueOf(goodsNum));
        boolean bo = player.getModule(CurrencyModule.class).removeCurrency(property, eLogMoneyType.YearMaster, eLogMoneyType.YearMasterItemUse);
        return bo;
    }


    /**
     * 进入活动拉取数据
     *
     * @return
     */
    public UserYearMasterDataResult getYearMasterInfo() {
        UserYearMasterDataResult result = new UserYearMasterDataResult();
        result.setRet(0);
        ActivityInfo activityInfo = YearMasterMgr.getActivityInfo();
        if (activityInfo == null || !ActivityMgr.activityInShowTime(activityInfo)) {
            result.setRet(GameErrorCode.E_ACTIVITY_NO_FOUND);
            return result;
        }

        YearMasterMgr.getYearMasterBoss();

        UserYearMasterData userYearMasterData = getUserYearMasterData(activityInfo.getActivityId());
        if (userYearMasterData != null) {
            result.setUserYearMasterData(userYearMasterData);
        }
        return result;
    }


    /**
     * @param indexList 消除格子下标
     * @param type      模式 0 普通  1高级
     * @return
     */

    public UserYearMasterDataResult playGame(List<Integer> indexList, int type) {

        UserYearMasterDataResult result = new UserYearMasterDataResult();

        ActivityInfo activityInfo = YearMasterMgr.getActivityInfo();

        //活动进行期间
        if (activityInfo == null || !ActivityMgr.activityInTime(activityInfo)) {
            result.setRet(GameErrorCode.E_ACTIVITY_NO_FOUND);
            return result;
        }

        UserYearMasterData userData = getUserYearMasterData(activityInfo.getActivityId());
        result.setRewords("");
        result.setRet(0);
        result.setUserYearMasterData(userData);

        //高级场解锁判定
        if(type == 1 && userData.getScore()<YearMasterMgr.getYearMasterActivityConfig().getHighOpenScore()){
            result.setRet(GameErrorCode.E_YEAR_MASTER_HIGH_MODE_NO_OPEN);
            return result;
        }

        // 旧配置不让用16倍
        if (type == 2 && YearMasterMgr.getYearMasterActivityConfig().getFastUnlockVipLevel() == Integer.MAX_VALUE) {
            result.setRet(GameErrorCode.E_YEAR_MASTER_HIGH_MODE_NO_OPEN);
            return result;
        }
        //急速场解锁判定
        if (type == 2 && VipMgr.getVipLv(player.getModule(PlayerModule.class).getUserInfo().getVipExp()) < YearMasterMgr.getYearMasterActivityConfig().getFastUnlockVipLevel()) {
            result.setRet(GameErrorCode.E_YEAR_MASTER_HIGH_MODE_NO_OPEN);
            return result;
        }

        //只能1,2,3,4,9,16
        if (indexList.size() == 0 || (indexList.size() > 4 && indexList.size() != 9 && indexList.size() != 16)) {
            result.setRet(GameErrorCode.E_YEAR_MASTER_GRID_NUM_ERROR);
            return result;
        }

        if (type > 2 || type < 0) {
            result.setRet(GameErrorCode.E_YEAR_MASTER_MODE_EMPTY);
            return result;
        }

        //下标校验
        if (!YearMasterMgr.checkGridIndex(indexList)) {
            result.setRet(GameErrorCode.E_YEAR_MASTER_ARGUMENT_ERROR);
            return result;
        }

        try {
            //1 更新体力
            StrengthResult strengthResult = PowerHelper.addPower(userData.getPhysicalStrength(), userData.getStrengthTime(), YearMasterMgr.getYearMasterActivityConfig().getStrengthConfig());//到期增加
            changeStrength(userData, strengthResult);

            int myPower = userData.getPhysicalStrength();
            //减少体力值
            int reducePowerNum = 0;

            //格子数据
            List<GridDetail> gridDetailList = null;
            if (type == 0) {
                //普通模式
                if ((myPower - YearMasterMgr.getYearMasterActivityConfig().getNormalPowerConsume()) < 0) {
                    result.setRet(GameErrorCode.E_YEAR_MASTER_STRENGTH_NOT_ENOUGH);
                    return result;
                }
                reducePowerNum = YearMasterMgr.getYearMasterActivityConfig().getNormalPowerConsume();

                gridDetailList = JSONObject.parseArray(userData.getPaint(), GridDetail.class);
            } else if (type == 1) {
                //高级模式
                if ((myPower - YearMasterMgr.getYearMasterActivityConfig().getHighPowerConsume()) < 0) {
                    result.setRet(GameErrorCode.E_YEAR_MASTER_STRENGTH_NOT_ENOUGH);
                    return result;
                }
                reducePowerNum = YearMasterMgr.getYearMasterActivityConfig().getHighPowerConsume();
                gridDetailList = JSONObject.parseArray(userData.getHighPaint(), GridDetail.class);
            } else if (type == 2) {
                // 急速模式
                if ((myPower - YearMasterMgr.getYearMasterActivityConfig().getFastPowerConsume()) < 0) {
                    result.setRet(GameErrorCode.E_YEAR_MASTER_STRENGTH_NOT_ENOUGH);
                    return result;
                }
                reducePowerNum = YearMasterMgr.getYearMasterActivityConfig().getFastPowerConsume();
                gridDetailList = JSONObject.parseArray(userData.getFastPaint(), GridDetail.class);
            }
            // 1 2 4(12349)
            if (indexList.size() > 1) {
                //  格子是否同种类
                if (!YearMasterMgr.checkGridType(indexList, gridDetailList)) {
                    result.setRet(GameErrorCode.E_YEAR_MASTER_GRID_TYPE);
                    return result;
                }
                // 格子是否相连
                if (indexList.size() == 2 && !YearMasterMgr.checkGridLink(indexList.get(0), indexList.get(1))) {
                    result.setRet(GameErrorCode.E_YEAR_MASTER_GRID_LINK);
                    return result;
                }
                // 格子是否三连
                if (indexList.size() == 3 && !YearMasterMgr.checkGridLink(indexList.get(0), indexList.get(1), indexList.get(2))) {
                    result.setRet(GameErrorCode.E_YEAR_MASTER_GRID_LINK);
                    return result;
                }
                // 是否正方形
                if (indexList.size() == 4 && !YearMasterMgr.checkGridSquare(indexList) && !YearMasterMgr.checkGridLink(indexList)) {
                    result.setRet(GameErrorCode.E_YEAR_MASTER_GRID_LINK);
                    return result;
                }
                // 是否九桶形
                if (indexList.size() == 9 && !YearMasterMgr.checkGridNineSquare(indexList)) {
                    result.setRet(GameErrorCode.E_YEAR_MASTER_GRID_LINK);
                    return result;
                }
                // 是否16个的正方形
                if (indexList.size() == 16 && !YearMasterMgr.checkGrid16Square(indexList)) {
                    result.setRet(GameErrorCode.E_YEAR_MASTER_GRID_LINK);
                    return result;
                }
            }


            //记录消除的格子
            List<GridDetail> deleteList = new ArrayList<>();
            for (int index : indexList) {
                deleteList.add(gridDetailList.get(index).copy());
            }

            //消除格子
            String changeIndexStr = YearMasterMgr.changeGrid(indexList, gridDetailList);

            int deleteGridType = deleteList.get(0) == null ? 0 : deleteList.get(0).getGridType();

            //计算消除获得喜庆值
            int resultScore = YearMasterMgr.getGridScore(deleteList, type);

            //根据权重生成新格子
            String newIndexStr = YearMasterMgr.fillGrid(gridDetailList);


            if (type == 1) {
                //更新格子
                userData.setHighPaint(JSONArray.toJSONString(gridDetailList));
            } else if (type == 0) {
                //更新格子
                userData.setPaint(JSONArray.toJSONString(gridDetailList));
            } else if (type == 2) {
                userData.setFastPaint(JSONArray.toJSONString(gridDetailList));
            }

            result.setUserYearMasterData(userData);


            //扣除体力值
            StrengthResult reduceStrengthRs = PowerHelper.reduceStrength(userData.getPhysicalStrength(), reducePowerNum, YearMasterMgr.getYearMasterActivityConfig().getStrengthConfig(), userData.getStrengthTime());
            changeStrength(userData, reduceStrengthRs);

            //推送格子改变
            syncGrid(newIndexStr, changeIndexStr, activityInfo.getActivityId(), gridDetailList, type);

            //跨服喜庆值处理
            if (resultScore > 0) {
                YearMasterProto.CrossAttackBossReqMsg.Builder builder = YearMasterProto.CrossAttackBossReqMsg.newBuilder();
                builder.setActivityId(activityInfo.getActivityId());
                builder.setScore(resultScore);
                builder.setUserId(player.getUserId());
                builder.setGridType(deleteGridType);
                builder.setGameMode(type);
                builder.setGridNum(indexList.size());
                builder.setRemoveGrid(StringUtils.listToString(indexList,"|"));
                //跨服
                player.sendPacket(CrossProtocol.C2_CROSS_YEAR_MASTER_ATTACK, builder);
            }

            //普通/高级场格子积分 = 消除物件个数*体力值
            int size = type == 1 ? indexList.size() * YearMasterMgr.getYearMasterActivityConfig().getHighPowerConsume()
                    : type == 0 ? indexList.size() * YearMasterMgr.getYearMasterActivityConfig().getNormalPowerConsume()
                    : indexList.size() * YearMasterMgr.getYearMasterActivityConfig().getFastPowerConsume();
            //消除格子成就
            player.notifyListener(eGamePlayerEventType.YearMasterItemTimes.getValue(), new YearMasterGridTypeArgs(deleteGridType, size));

            //logger.debug(result.getUserYearMasterData());
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("playGame:" + e);
        }

        return result;
    }


    /**
     * 跨服消除响应
     *
     * @param activityId
     * @param score
     * @param bossInfo
     * @return
     */
    public UserYearMasterDataResult playGameCrossHandle(int activityId, long score, YearMasterProto.YearMasterBossInfo bossInfo,int gridType,int gridNum,int mode) {
        UserYearMasterDataResult result = new UserYearMasterDataResult();
        UserYearMasterData userData = getUserYearMasterData(activityId);
        result.setRet(0);
        result.setUserYearMasterData(userData);

        if (score > 0) {
            userData.setScore(userData.getScore() + score);

            Property reword = new Property(eItemId.YEAR_MASTER_SCORE.getValue(), BigInteger.valueOf(score));
            //增加分数
            player.getModule(CurrencyModule.class).addCurrency(reword, eLogMoneyType.YearMaster, eLogMoneyType.YearMasterScoreReword);

            String rewordStr = PropertyHelper.parsePropertyToString(reword);
            //本次奖励
            result.setRewords(rewordStr);
            //积分成就
            player.notifyListener(eGamePlayerEventType.YearMasterScoreCrossRank.getValue(), userData.getScore());
            player.notifyListener(eGamePlayerEventType.YearMasterScoreRank.getValue(), userData.getScore());
            AutoLogMgr.add(new LogYearMaster(player.getUserId(), activityId, mode, gridType, gridNum, rewordStr));
        }

        //更新boss数据
        YearMasterMgr.updateBossInfo(bossInfo, false);

        //先更新boss 再更新boss成就
        player.notifyListener(eGamePlayerEventType.YearMasterBossState.getValue(), YearMasterMgr.getYearMasterBoss());

        return result;
    }


    private UserYearMasterData getUserYearMasterData(int activityId) {
        ActivityInfo activityInfo = YearMasterMgr.getActivityInfo();
        if (activityInfo != null && ActivityMgr.activityInShowTime(activityInfo)) {
            if (!userYearMasterDataMap.containsKey(activityId)) {
                long nowTime = System.currentTimeMillis();
                UserYearMasterData userYearMasterData = new UserYearMasterData();
                userYearMasterData.setActivityId(activityId);
                userYearMasterData.setUserId(player.getUserId());
                userYearMasterData.setLastUpdateTime(nowTime);
                userYearMasterData.setStrengthTime(nowTime);
                userYearMasterData.setPhysicalStrength(YearMasterMgr.getYearMasterActivityConfig().getStrengthConfig().getMaxStrength()); //体力值
                userYearMasterData.setInsertOption();
                //初始化配置格子 分普通和高级场
                List<GridDetail> configGridList = YearMasterMgr.getConfigGridList(0);
                List<GridDetail> highConfigGridList = YearMasterMgr.getConfigGridList(1);
                List<GridDetail> fastConfigGridList = YearMasterMgr.getConfigGridList(2);
                userYearMasterData.setPaint(JSONArray.toJSONString(configGridList));
                userYearMasterData.setHighPaint(JSONArray.toJSONString(highConfigGridList));
                userYearMasterData.setFastPaint(JSONArray.toJSONString(fastConfigGridList));

                userYearMasterDataMap.put(activityId, userYearMasterData);
            }
        }
        return userYearMasterDataMap.get(activityId);
    }


    /**
     * 同步体力值
     *
     * @param userYearMasterData
     */
    public void syncStrength(UserYearMasterData userYearMasterData) {
        YearMasterProto.YearMasterRefreshStrengthMsg.Builder respMsg = YearMasterProto.YearMasterRefreshStrengthMsg.newBuilder();
        respMsg.setStrength(userYearMasterData.getPhysicalStrength());
        respMsg.setNextRefreshTime(userYearMasterData.getStrengthTime() / 1000);
        respMsg.setActivityId(userYearMasterData.getActivityId());
        player.sendPacket(Protocol.U_YEAR_MASTER_REFRESH_STRENGTH, respMsg);
    }

    /**
     * 更新体力值
     *
     * @param userData
     * @param strengthResult
     */
    public void changeStrength(UserYearMasterData userData, StrengthResult strengthResult) {
        if (strengthResult != null) {
            userData.setPhysicalStrength(strengthResult.getStrength());
            userData.setLastUpdateTime(strengthResult.getLastUpdateTime());
            userData.setStrengthTime(strengthResult.getStrengthUpdateTime());
            //更新体力值
            syncStrength(userData);
        }
    }

    /**
     * 同步格子改变
     *
     * @param newStr
     * @param changeStr
     * @param activityId
     * @param gridList
     * @param type
     */
    private void syncGrid(String newStr, String changeStr, int activityId, List<GridDetail> gridList, int type) {

        YearMasterProto.YearMasterGridPaintChangeMsg.Builder builder = YearMasterProto.YearMasterGridPaintChangeMsg.newBuilder();
        builder.setActivityId(activityId);
        builder.setType(type);
        if (gridList == null) {
            return;
        }
        builder.addAllPaint(YearMasterPb.parseGridMsgList(gridList));
        if (changeStr != null) {
            builder.setChangeGridStr(changeStr);
        }
        if (newStr != null) {
            builder.setNewGridStr(newStr);
        }
        //System.out.println(builder.getNewGridStr() + "*****" + builder.getChangeGridStr());
        player.sendPacket(Protocol.U_YEAR_MASTER_GRID_CHANGE, builder);

    }


    /**
     * 同步活动数据
     */
    public void syncActivity() {
        if (SystemOpenMgr.systemOpen(player, eSystemId.YearMaster.getValue())) {
            //正在开放的活动
            ActivityInfo activityInfo = YearMasterMgr.getActivityInfo();
            if (activityInfo != null && ActivityMgr.activityInShowTime(activityInfo)) {
                //初始化数据
                UserYearMasterData userYearMasterData = getUserYearMasterData(activityInfo.getActivityId());
                //成就
                YearMasterBoss yearMasterBoss = YearMasterMgr.getYearMasterBoss();
                log.debug("yearMasterBoss:" + yearMasterBoss.getTotalBlood() + "  " + yearMasterBoss.getCurrentBlood() + "  " + yearMasterBoss.getState());
                if (yearMasterBoss != null) {
                    //同步一下玩家下线期间boss状态改变
                    player.notifyListener(eGamePlayerEventType.YearMasterBossState.getValue(), yearMasterBoss);
                }
                player.sendPacket(ClientProtocol.U_YEAR_MASTER_ACTIVITY_DATA, YearMasterPb.parseActivityInfo(YearMasterMgr.getYearMasterActivityConfig().getStrengthConfig(), userYearMasterData, yearMasterBoss,YearMasterMgr.getYearMasterActivityConfig().getStateHpMap(),YearMasterMgr.getYearMasterActivityConfig().getHighOpenScore()));
                //自动转换道具积分
                autoUseActivityGoods(activityInfo);
            }
        }
    }

    /**
     * 送财烟火
     *
     * @param activityInfo
     * @param manifesto
     * @return
     */
    public ActivityDisperseGoldResult disperseGold(ActivityInfo activityInfo, String manifesto) {
        ActivityDisperseGoldResult result = new ActivityDisperseGoldResult();
        if (activityInfo.getActivityId() != YearMasterMgr.getActivityInfo().getActivityId()) {
            result.setRet(GameErrorCode.E_YEAR_MASTER_ARGUMENT_ERROR);
            return result;
        }
        if (!ActivityMgr.activityInShowTime(activityInfo)) {
            result.setRet(GameErrorCode.E_YEAR_MASTER_ACTIVITY_NO_IN_TIME);
            return result;
        }

        //送财消耗
        Property consume = new Property(eItemId.YEAR_MASTER_FIREWORKS.getValue(), BigInteger.ONE);
        if (!player.getModule(CurrencyModule.class).removeCurrency(consume, eLogMoneyType.YearMaster, eLogMoneyType.YearMasterDisperseGold)) {
            result.setRet(GameErrorCode.E_YEAR_MASTER_DISPERSE_GOLD_ITEM_NO_ENOUGH);
            return result;
        }
        List<Integer> decorationIdList = player.getModule(DecorationModule.class).getDecorationIdList(eDecorationType.HonoraryTitle.getValue());
        ActivityDisperseGoldInfo goldInfo = new ActivityDisperseGoldInfo();
        goldInfo.setActivityId(activityInfo.getActivityId());
        goldInfo.setType(activityInfo.getType());
        goldInfo.setUserId(player.getUserId());
        goldInfo.setManifesto(manifesto);
        goldInfo.setBeginTime(System.currentTimeMillis());
        goldInfo.setHonoraryTitles(StringUtils.listToString(decorationIdList, ","));

        if (NormalActivityMgr.hasConditionType(activityInfo.getActivityId(), eGamePlayerEventType.YearMasterScoreCrossRank.getValue())) {
            goldInfo.setServerList(activityInfo.getServerIdList());
        } else {
            List<Long> serverList = new ArrayList<>();
            serverList.add(GameServer.getInstance().getServerId());
            goldInfo.setServerList(serverList);
        }
        goldInfo.setUserBaseInfo(UserMgr.getUserBaseInfo(player.getUserId(), GameServer.getInstance().getServerId()));
        result.setGoldInfo(goldInfo);
        return result;
    }

    /**
     * 消耗道具
     *
     * @param activityInfo
     */
    public void autoUseActivityGoods(ActivityInfo activityInfo) {
        if (ActivityMgr.activityInShowPeriod(activityInfo) || ActivityMgr.activityInRewardPeriod(activityInfo)) {//在展示期或者领奖期
        //    BagModule bagModule = player.getModule(BagModule.class);
         //   bagModule.removeActivityBagItemToScore(activityInfo, eItemId.YEAR_MASTER_SCORE.getValue(), eItemId.YEAR_MASTER_EGG.getValue(), 2, MailManager.YEAR_MASTER_ACTIVITY_GOODS_AUTO_CONSUME_TITLE, MailManager.YEAR_MASTER_ACTIVITY_GOODS_AUTO_CONSUME_CONTENT);   //体力恢复道具
        }
    }
}
